using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAO;
using System.Data;

namespace BUS
{
    /// <summary> 
    ///Author: daiduong19051986@gmail.com 
    /// <summary>
    public class csreportgroupdetailControl
    {
        #region Local Variable
        private csreportgroupdetailDataAccess _objDAO;
        #endregion Local Variable

        #region Method
        public csreportgroupdetailControl()
        {
            _objDAO = new csreportgroupdetailDataAccess();
        }

        public csreportgroupdetailInfo Get(
        String DB,
        String reportgroup,
        String reportcode,
        ref string sErr)
        {
            return _objDAO.Get(
            DB,
            reportgroup,
            reportcode,
            ref sErr);
        }

        public DataTable GetAll(
        ref string sErr)
        {
            return _objDAO.GetAll(
            ref sErr);
        }

        public Int32 Add(csreportgroupdetailInfo obj, ref string sErr)
        {
            return _objDAO.Add(obj, ref sErr);
        }

        public string Update(csreportgroupdetailInfo obj)
        {
            return _objDAO.Update(obj);
        }

        public string Delete(
        String DB,
        String reportgroup,
        String reportcode
        )
        {
            return _objDAO.Delete(
            DB,
            reportgroup,
            reportcode
            );
        }
        public Boolean IsExist(
        String DB,
        String reportgroup,
        String reportcode
        )
        {
            return _objDAO.IsExist(
            DB,
            reportgroup,
            reportcode
            );
        }


        public DataTable Search(String columnName, String columnValue, String condition, String tableName, ref String sErr)
        {
            return _objDAO.Search(columnName, columnValue, condition, tableName, ref  sErr);
        }
        public string InsertUpdate(csreportgroupdetailInfo obj)
        {
            string sErr = "";
            if (IsExist(
            obj.DB,
            obj.reportgroup,
            obj.reportcode
            ))
            {
                sErr = Update(obj);
            }
            else
                Add(obj, ref sErr);
            return sErr;
        }

        public DataTable GetTransferOut(string dtb, object from, object to, ref string sErr)
        {
            return _objDAO.GetTransferOut(dtb, from, to, ref sErr);
        }

        public DataTable ToTransferInStruct()
        {
            csreportgroupdetailInfo inf = new csreportgroupdetailInfo();
            return inf.ToDataTable();
        }

        public string TransferIn(DataRow row)
        {
            csreportgroupdetailInfo inf = new csreportgroupdetailInfo(row);
            return InsertUpdate(inf);
        }
        #endregion Method


        public DataTable GetbyGroup(String DB, string ReportGroup, string busID, ref string sErr)
        {
            return _objDAO.GetReportGroup(DB, ReportGroup, busID, ref sErr);
        }

        public string Deletes(string DB, string ReportGroup)
        {
            return _objDAO.Delete(
            DB,
            ReportGroup
            );
        }
    }
}
